package com.itheima.utils;

import redis.clients.jedis.Jedis;
import redis.clients.jedis.JedisPool;
import redis.clients.jedis.JedisPoolConfig;

import java.util.ResourceBundle;

public class JedisUtils {
    public static Jedis getJedis(){
        ResourceBundle bundle = ResourceBundle.getBundle("Jedis");
        JedisPoolConfig jedisPoolConfig = new JedisPoolConfig();
        //最大连接数
        jedisPoolConfig.setMaxTotal(Integer.parseInt(bundle.getString("MaxTotal")));
        //空闲时的连接数
        jedisPoolConfig.setMaxIdle(Integer.parseInt(bundle.getString("MaxIdle")));
        JedisPool jedisPool = new JedisPool(jedisPoolConfig, bundle.getString("localhost"), Integer.parseInt(bundle.getString("port")));
        return jedisPool.getResource();
    }
}
